<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商家管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <style>
        thead tr th{text-align: center!important;}
        tr td{text-align: center!important;}
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form id="seachFrom" class="layui-form">
                    <div class="layui-card-body">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>活动名称</th>
                                <th>活动开始时间</th>
                                <th>活动结束时间</th>
                                <th>创建时间</th>
                                <th>活动状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${pageInfo.records}" var="l">
                                <tr>
                                    <td width="5%">${l.id}</td>
                                    <td width="10%">${l.name}</td>
                                    <td width="10%"><fmt:formatDate value="${l.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                                    <td width="10%"><fmt:formatDate value="${l.overTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                                    <td width="10%"><fmt:formatDate value="${l.createTime}" pattern="yyyy-MM-dd HH:mm"></fmt:formatDate></td>
                                    <td width="6%">
                                        <c:if test="${l.status==1}"><span class="layui-badge layui-bg-green">有效</span></c:if>
                                        <c:if test="${l.status==0}"><span class="layui-badge">无效</span></c:if>
                                    </td>
                                    <td width="12%">
                                        <button data-id="${l.id}" data-type="enter" type="button" class="layui-btn layui-btn-sm layui-btn-normal enter">进入</button>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <div class="test-table-reload-btn" style="margin-top: 10px;">
                            <%@include file="../paging.jsp" %>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var form = layui.form;
        var active = {
            enter:function(id){
                window.location.href = "/activity/seckillDetail?id="+id;
            },
            updateThis:function (id,status,url) {
                layer.confirm('确定操作吗？', function(){
                    $.ajax({
                        url: url,
                        data: {"id": id, 'status': status},
                        dataType: "json",
                        type: "post",
                        success: function (data) {
                            if (data.status) {
                                layer.msg(data.desc,{icon:1});
                                setTimeout(function () {
                                    window.location.reload();
                                }, 1000)
                            } else {
                                layer.msg(data.desc,{icon:2});
                            }
                        }
                    });
                });
            }
        };
        $('.enter').on('click',function () {
            var type = $(this).data('type');
            var id = $(this).data('id');
            active[type] && active[type].call(this,id);
        });
    });
</script>
</body>
</html>